package com.jianzh5.test;

import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;

/**
 * <p>
 * <code>Strdent</code>
 * </p>
 *
 * @author jianzhang11
 * @version 1.0
 * @desc
 * @Date: 2016/9/26 15:21
 * @since 1.0
 */
public  class Strdent implements Comparable<Strdent>{
    private String name;
    private int score;

    public Strdent(String name, int score) {
        this.name = name;
        this.score = score;
    }

    @Override public int compareTo(Strdent o) {
        if(o.score < this.score)
            return -1;
        else if(o.score > this.score)
            return 1;
        return 0;
    }

    @Override public String toString() {
        return "Strdent{" +
                "name='" + name + '\'' +
                ", score=" + score +
                '}';
    }

    public static void main(String[] args) {
        Map map = new TreeMap();
        Strdent s1 = new Strdent("jianzh5",100);
        Strdent s2 = new Strdent("jianzhang11",80);
        Strdent s3 = new Strdent("hello",90);
        Strdent s4 = new Strdent("hello",92);

        map.put(s1,s1);
        map.put(s2,s2);
        map.put(s3,s3);
        map.put(s4,s4);

        System.out.println(map.keySet());

        Map map2 = ((TreeMap)map).tailMap(s3);
        for(Iterator it = map2.keySet().iterator();it.hasNext();){
            System.out.println(map.get(it.next()));
        }
    }
}
